<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class HelpAddress extends Model
{
    protected $dateFormat = 'U';
    protected $table = "lexiang_help_address";
    protected $primaryKey = 'address_id';

    public function saveadd($data)
    {
    	$info = $this->where('user_id',$data['user_id'])->first();
    	if(!$info){
    		$info = $this;
    	}
    	$info->name = $data['name'];
    	$info->address = $data['address'];
    	$info->tel = $data['tel'];
    	$info->user_id = $data['user_id'];

    	if($info->save()){
    		return [
    			'success'=>true,
    			'code'=>'000',
    			'message'=>'保存成功'
    		];
    	}else{
    		return [
    			'success'=>false,
    			'code'=>'006',
    			'message'=>'保存出错，请稍后再试'
    		];
    	}
    }
}
